/*
 * Copyright 2014 Jonathan Haas
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package app.grinreader.model;

import android.graphics.Typeface;
import android.text.TextPaint;

/**
 *
 */
public class StyleElement implements Element {

	private int textStyle = Typeface.NORMAL;
	private float textScale = 1.0f;
	private float textScaleX = 1.0f;
	private float baselineOffset = 0.0f;
	private float marginTop = 0.0f;
	private float marginBottom = 0.0f;
	private float marginLeft = 0.0f;
	private float marginRight = 0.0f;
	private float textIndent = 0.0f;
	private boolean centered = false;
	private boolean pageBreak = false;

	public int getTextStyle() {
		return textStyle;
	}

	public void setTextStyle(int textStyle) {
		this.textStyle = textStyle;
	}

	public float getTextScale() {
		return textScale;
	}

	public void setTextScale(float textScale) {
		this.textScale = textScale;
	}

	public float getTextScaleX() {
		return textScaleX;
	}

	public void setTextScaleX(float textScaleX) {
		this.textScaleX = textScaleX;
	}

	public float getBaselineOffset() {
		return baselineOffset;
	}

	public void setBaselineOffset(float baselineOffset) {
		this.baselineOffset = baselineOffset;
	}

	public float getMarginTop() {
		return marginTop;
	}

	public void setMarginTop(float marginTop) {
		this.marginTop = marginTop;
	}

	public float getMarginBottom() {
		return marginBottom;
	}

	public void setMarginBottom(float marginBottom) {
		this.marginBottom = marginBottom;
	}

	public float getMarginLeft() {
		return marginLeft;
	}

	public void setMarginLeft(float marginLeft) {
		this.marginLeft = marginLeft;
	}

	public float getMarginRight() {
		return marginRight;
	}

	public void setMarginRight(float marginRight) {
		this.marginRight = marginRight;
	}

	public float getTextIndent() {
		return textIndent;
	}

	public void setTextIndent(float textIndent) {
		this.textIndent = textIndent;
	}

	public boolean isCentered() {
		return centered;
	}

	public void setCentered(boolean centered) {
		this.centered = centered;
	}

	public boolean isPageBreak() {
		return pageBreak;
	}

	public void setPageBreak(boolean pageBreak) {
		this.pageBreak = pageBreak;
	}

	public void adjustPaint(TextPaint paint){
		Typeface typeface = paint.getTypeface();
		paint.setTypeface(Typeface.create(typeface, typeface.getStyle() | textStyle));
		paint.setTextSize(paint.getTextSize() * textScale);
		paint.setTextScaleX(paint.getTextScaleX() *textScaleX);
	}

}
